summaryrefslogtreecommitdiff
path: root/src/main.cpp
blob: 2b20e66d8b74eca2aa5ae2452711b3d86060f854 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "gamebuilder.h"
#include "game.h"
#include "gamestate.h"
#include "parser.tab.h"

#include <bu/sio.h>
using namespace Bu;

typedef void *yyscan_t;
void yylex_init( yyscan_t * );
void yylex_destroy( yyscan_t );
void yyparse( yyscan_t, GameBuilder &bld );
void yyset_in( FILE *, yyscan_t );

int main( int argc, char *argv[] )
{
	yyscan_t scanner;

	GameBuilder bld;

	yylex_init( &scanner );

	FILE *in = fopen( argv[1], "rb" );
	yyset_in( in, scanner );

	yyparse( scanner, bld );
	yylex_destroy( scanner );

	fclose( in );

	Game *pGame = bld.getGame();

	GameState gs( pGame );
	gs.init();

	char buf[1024];
	sio << ">>" << sio.flush;
	fgets( buf, 1024, stdin );

	sio << "Read: >" << buf << "<" << sio.nl;
	gs.execCommand( buf );

	return 0;
}